package main

import "fmt"

type B struct {
	name string
	id   int
}
type BB struct {
	*B  // 指针类型，初始化时要带&
	add string
}

func main() {
	bb := BB{&B{"mike", 1}, "sh"}
	fmt.Println("bb =", bb) // bb = {0xc000008030 sh}

	bb.name = "lucy"
	fmt.Println("bb.name =", bb.name) // bb.name = lucy

	bb.B = new(B)                  // 可以先分配空间
	fmt.Println("bb.B =", *(bb.B)) // bb.B = { 0}

	bb.name = "alfo"
	fmt.Println("bb.name =", bb.name) // bb.name = alfo
}
